package com.yupi.springbootinit.BiMQ.BiMq;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Slf4j
public class BiDlxConsumer {

    /**
     * @param message
     * @param channel
     * @param deliveryTag
     * @throws Exception
     */
    @RabbitListener(queues = {BIMQConstant.BI_DLX_QUEUE_NAME},ackMode = "MANUAL")
    public void receive(String message, Channel channel,
                        @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) throws Exception {
        log.info("死信队列的消息：message{}",message);
        channel.basicAck(deliveryTag,false);
    }

}
